package qeug.shsh.opplugin;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;

import java.util.EventObject;

//预算调整单，业务单元分配部门寻找部门对应公司
public class AdjustBillPlugin extends AbstractFormPlugin{

    @Override
    public void afterCreateNewData(EventObject e) {
        super.afterCreateNewData(e);
        DynamicObject department = (DynamicObject) this.getModel().getValue("department");//部门
        QFilter[] a = new QFilter[]{new QFilter("toorg.number", "=", department.getString("number"))};
        DynamicObject bos_dailyapplybil = BusinessDataServiceHelper.loadSingle("bos_org_orgrelation_dept", a);//业务单元分配部门
        if (bos_dailyapplybil != null){
            DynamicObject fromorg = bos_dailyapplybil.getDynamicObject("fromorg");//业务单元
            this.getModel().setValue("qeug_company" , fromorg);//公司
        }
    }
}
